﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TXK;

namespace WpfApp1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            
            DevXMZ devXMZ = new DevXMZ();
            devXMZ.LoadConFigByExcel();
            #region chushihua
       //     devXMZ.VariableAll.Add(new SiemensVar()
       //     {
       //         VarAddress = "DB1.0",
       //         StoreType = StoreType.DataBlock,
       //         VarName = "asdf",
       //         Value = 3.134,
       //         DataType = TXK.CommonBase.DataType.Float,
       //         HighAlarmEnable = true,
       //         HighAlarmValue = 10,
       //         AlarmEnable = true,
       //         AlarmType = TXK.CommonBase.AlarmType.条件报警
       //     }
       //);
       //     devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "DB1.4.2", VarName = "bian", StoreType = StoreType.DataBlock, AlarmType = TXK.CommonBase.AlarmType.离散报警, AlarmEnable = true, Value = "", DiscreteAlarmType = TXK.CommonBase.DiscreteAlarmType.上升沿报警 });
       //     devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "DB1.14", StoreType = StoreType.DataBlock, VarName = "asdf啊", Value = 23.78, DataType = TXK.CommonBase.DataType.Float });
       //     devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "DB1.20", StoreType = StoreType.DataBlock });
       //     devXMZ.VariableAll.Add(new SiemensVar() { VarAddress = "mb20", StoreType = StoreType.Marker });
            #endregion

            devXMZ.AlarmEvent += DevXMZ_AlarmEvent;
            
            devXMZ.Start();
            //devXMZ.SaveAsJson();
          //  devXMZ.SaveAsExcel();
            this.DataContext = devXMZ;
         
        }

        private void DevXMZ_AlarmEvent(object sender, EventArgs e)
        {
           // throw new NotImplementedException();
        }
    }
}
